#include "ResourceManager.h"
#include "Environment.h"
#include <iostream>

namespace phnq
{
	namespace phnqlets
	{
		ResourceManager* ResourceManager::getInstance()
		{
			static ResourceManager instance;
		
			return &instance;
		}
	
		ResourceManager::ResourceManager()
		{
			// a little constructor action
		}

		ResourceManager::~ResourceManager()
		{
			// a little destructor action
		}

		string ResourceManager::findResource(string relPath)
		{
			vector<string> resPaths = Environment::getInstance()->getResourcePaths();
		
			int i = resPaths.size();
			for(int i=0; i<resPaths.size(); i++)
			{
				string s = resPaths[i];
				string path = s + "/" + relPath;
			
				if(fopen (path.c_str(),"r"))
					return path;
			}
			return "";
		}
	}
}
